/**
 * 处理方块逻辑
 */

/**
 *
 * @param {Array} matrix
 * @returns {Array}
 */
export function getBoxBottomPoints (matrix) {
  // todo 还有问题待解决
  const row = matrix.length
  const col = matrix[0].length
  const points = []
  for (let j = 0; j < col; j++) {
    // point
    const x = j
    const y = row - 1
    const point = {
      x,
      y
    }
    if (matrix[y][x]) {
      points.push(point)
    }
  }
  return points
}

export function rotate (matrix) {
  const row = matrix.length
  const col = matrix[0].length
  const r = []
  // 逆时针转90度
  for (let i = 0; i < row; i++) {
    for (let j = 0; j < col; j++) {
      const k = row - 1 - j // 行 = n - 1 - 列(j)
      if (!r[k]) {
        r[k] = []
      }
      r[k][i] = matrix[i][j]// 列 = 行
    }
  }
  return r
}
